const electron = require('electron');
const ipcMain = electron.ipcMain;
const head = 'kugou/';
const rank = require("../modules/kugou/playlist/rank")
const detail = require("../modules/kugou/playlist/detail")
const play = require("../modules/kugou/play")
const search = require("../modules/kugou/search")
const lrc = require("../modules/kugou/lrc")
module.exports = class kugou {

    init() {

        /**
         * 歌单推荐
         */
        ipcMain.handle(head+'list/rank', async (event, args) => {
            return await rank();

        });
        /**
         * 歌单详情
         */
        ipcMain.handle(head+'list/detail', async (event, args) => {
            return detail(args.id)
        });

        /**
         * 播放地址
         */
        ipcMain.handle(head+'play', async (event, args) => {
            return play(args.id)
        });
        /**
         * 搜索歌曲
         */
        ipcMain.handle(head+'search', async (event, args) => {

            return search(encodeURI(args.keyword)
                ,args.page || 1,
                args.pagesize || 30
            )
        });
        /**
         * 专辑内容
         */
        ipcMain.handle(head+'lrc', async (event, args) => {

            return lrc(args.id,args.albumid)
        });

    }

}
